package sivin.camera

import android.content.Context
import android.hardware.camera2.CameraDevice
import android.hardware.camera2.CameraManager
import android.util.Log
import android.util.Size
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

data class CameraDesireParams(@CameraFacing val desireFacing: String, val desireOutputSize: Size)

class CameraEngine(
    private val context: Context,
    private val coroutineScope: CoroutineScope
) {

    lateinit var desireParams: CameraDesireParams

    private lateinit var camera: CameraDevice
    private var outputSize: Size = Size(1920, 1080)

    private val cameraManager: CameraManager by lazy {
        context.getSystemService(CameraManager::class.java)
    }


    fun configure(): Boolean {
        if (!::desireParams.isInitialized) {
            throw IllegalArgumentException("please input desireParams before configure")
        }
        var cameraInfoList = CameraUtil.chooseAvailableResolution(
            desireParams.desireFacing,
            desireParams.desireOutputSize
        )

        return true
    }

    fun startCamera() = coroutineScope.launch(Dispatchers.Main) {

//        camera = openCamera(cameraManager, args.cameraId, cameraHandler)
    }


}